package com.shiminghui;

import java.util.ArrayList;

public class Test6 {
    public static void main(String[] args) {

        ArrayList<Phone> list = new ArrayList<>();

        Phone phone = new Phone("asd",8990);

        Phone phone1 = new Phone("sdd",8870);

        Phone phone2 = new Phone("zxc",9089);

        list.add(phone);
        list.add(phone1);
        list.add(phone2);

        ArrayList<Phone> arrayList = qurey(list);
        for (int i = 0; i < arrayList.size(); i++) {
            System.out.println(arrayList.get(i).getName()+" "+arrayList.get(i).getPrice());
        }


    }

    public static ArrayList<Phone> qurey(ArrayList<Phone> list){

        ArrayList<Phone> arrayList = new ArrayList<>();
        for (int i = 0; i < list.size(); i++) {
            if (list.get(i).getPrice()>5000){
                arrayList.add(list.get(i));
            }
        }
        return arrayList;
    }
}
